<@master template="master/master-loan"  title="怡亚通380金服__手机号码修改">
<div class="registerBar">
	<div class="mainbox">
    	<div class="registerBox">
        	<div class=""><span class="fs24">确定手机号码</span></div>
            <div class="inpLi">
            	<ul>
                	<li class="mt10">
                    	<div class="inpTit fl">手机号</div>
                    	<input name="mobile" type="text" class="dlInp" value="${member.mobile}" readonly="readonly" >
                    </li>
                  
                    
                    <li class="mt15">
                    	<img src="/common/getCaptcha" id="Img" style="width:90px; height:34px;" class='fr yzmImg yamIco' style=" width:1.3rem;">
                    	<div class="inpTit fl">图形验证码</div>
                    	<input name="erifyCode" type="text" class="dlInp" style="width:130px" placeholder="请输入图形验证码">
                    </li>
                    <li class="mt15">
                    	<span id="verfyBtn" class="hqymz fr" >获取验证码</span>
                    	<div class="inpTit fl" >短信验证码</div>
                    	<input name="authCode" type="text" class="dlInp" style="width:130px" placeholder="请填写短信验证码">
                    </li>
                </ul>
                <a id="submitBtn" href="#" class="ldBtn mt20">下一步</a>
            </div>
           
        </div>
    </div>
	</div>
	<@include file="/common/footer"/>
	<@include file="/common/protocol"/>
	<@js>  
	  $(document).ready(function(){
	  	  document.getElementById("zpbg").style.height = $(document).scrollTop()+document.body.clientHeight + 'px'; 
	  	  $("#pfProtocol").bind("click",function(){
		  	 $('#zpbg').show();
		  });
		  $("#zpbgBtn").bind("click",function(){
		  	 $('#zpbg').hide();
		  });
		  $("#Img").bind("click",function(){
		  	 var img = document.getElementById("Img");  
	         img.src = "/common/getCaptcha?rnd=" + Math.random();  
		  });
		  $("#verfyBtn").bind("click",function(){
		  	 if(!validate())
					return false;
		  	 var mobile = $("input[name='mobile']").val();
    		 var erifyCode = $("input[name='erifyCode']").val();	
		  	 $.getJSON("/common/checkCaptcha",{captcha:erifyCode},function(result){
	    			if(result.data == true){
	    				if (countdown == 60) {
	    					$.getJSON("/msg/rest/sendAuthCode",{phone:mobile},function(result){
				    		if(result.data.success){
				   					$.actionDialog({message : '短信已发送成功，请注意查收'});
				   					settime();
				   				}else{
				   					$.actionDialog({message : result.data.errMsg});
				   				}
				    		});
	    				}
	   				}else{
	   					$.actionDialog({message : '图片验证码错误'});
	   				}
	    		});
		  	 
		  });
		  $("#submitBtn").bind("click",function(){
				var _this = $(this);
				if(!validate())
					return false;
				var authCode = $("input[name='authCode']").val();
	    		if(!authCode){
	    			$.actionDialog({message : '请输入短信验证码'});
	    			return false;
	    		}	
				var mobile = $("input[name='mobile']").val();
	    	
	    		var authCode = $("input[name='authCode']").val();	
	    		$.getJSON("/msg/rest/checkAuthCode",{phone:mobile,authCode:authCode},function(result){
	    			if(result.data.success){
	   					window.location.href="/uc/modifyphone/next";
	   					
	   				}else{
	   					$.actionDialog({message : result.data.errMsg});
	   				}
	    		});
			
			});
			
			function validate(){
				var mobile = $("input[name='mobile']").val();
	    		var mobileCheck = $.fn.validate.mobile(mobile);
	    		if(!mobileCheck.isSuccess){
	    			$.actionDialog({message : mobileCheck.errorMsg});
	    			return false;
	    		}
	    		if(mobile!=${member.mobile})
	    		{
	    		     $.actionDialog({message : '输入的手机号码与当前绑定的手机号码不一致！'});
	    		     return false;
	    		}

	    		var erifyCode = $("input[name='erifyCode']").val();
	    		if(!erifyCode){
	    			$.actionDialog({message : '请输入图片验证码'});
	    			return false;
	    		}
	    		return true;
			}
		})
		var countdown=60; 
		function settime() { 
			if (countdown == 0) { 
				countdown = 60; 
				$("#verfyBtn").attr("class","hqymz fr")
				$("#verfyBtn").html("获取验证码");
			} else { 
				$("#verfyBtn").attr("class","hqymz1 fr")
				$("#verfyBtn").attr("disabled", true); 
				$("#verfyBtn").html("重新发送(" + countdown + "s)");
				countdown--; 
				setTimeout(function() { 
					settime() 
				},1000) 
			} 
		} 
	</@js>
	<@jsRender/>  
</@master>